#!/usr/bin/env python
# -- coding: utf-8 --
'''=================================================
@Project -> File   ：BMOrderManage_2021-3-1 -> skip_code
@IDE    ：PyCharm
@Author ：Json
@Date   ：2021-12-27 11:21
@Desc   ：不再使用斐斐打码，采用第三方库，ddddocr
        作者微博
        https://wenanzhe.com/

=================================================='''

import ddddocr as dr

import logging

logger = logging.getLogger(__name__)


class SkipCode:
    ocr = dr.DdddOcr(show_ad=False)

    def get_code(self, image_base64):
        code = self.ocr.classification(image_base64)
        logger.info(f'验证码为{code}')
        return code


if __name__ == '__main__':
    skipcode = SkipCode()
    # 二进制方式打开图片文件
    # f = open(r'D:\project\BMOrderManage_2021-3-1\CS\utils\skip_vscode_2\code_image\acqs.png', 'rb')
    f = open(r'./code_image/temp.png', 'rb')

    image_base64 = 'iVBORw0KGgoAAAANSUhEUgAAAKAAAAA0CAIAAACCWqQvAAALG0lEQVR4Xu2biT9U+xvH7//Zvf2kIsY+xlbKXrJlTylZQjQGDSpFluxdrRJRQpZWiRrU3Ldzau7xxURljnt+5/Pymtf4LmeO7+d5Ps/nOVN/2HVoGn+IAzq0BZ1gjUMnWOPQCdY4dII1Dp1gjUMnWOPQCdY4dII1Dm0SvLS0lJJ+2hga9WjgiTj3fwb1CX72/MWDR495FSe2gNFnY5aa+iNRJ6Ljk9My8+KOp+UXXOzqvvN8bDzsSFxIROzN5jZxz87DZlsSh9SDygTPf/x4yCdkr7vP3v2+0zOz4vTmeDE+GXcibf+hIC/fEAgur6w+X1jGSExC6sDg0O3Ono6u3pRTuddv3BJ3bo6VL1/mPswTatyVOLc5Jl9OoxOd3X29fXf5E969n/MJjPi4sNjW3mWtb/zy5Yu4wbVQmeAbTa2pGXmJyZkFReVlFRZxeiN8/fq1tLzKz3iEmPANjDAEhEdGJ162WOHy9Nmi+MT0lrYODv3x4HDRxYrGplZx/zpAasO1JqJhv2eg20F/D0Mw1zwWm1RSehklEFcrQAwlpmT9uc/Alj1u3n+5+/De2z80Ki75St11Y1gU40vLy+I210JlggsK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